package com.wicket.okrframework.web.contorller;

import com.github.pagehelper.Page;
import com.wicket.okrframework.biz.service.StationService;
import com.wicket.okrframework.biz.service.dto.req.*;
import com.wicket.okrframework.biz.service.dto.res.*;
import com.wicket.okrframework.common.ro.OkrResult;
import com.wicket.okrframework.common.util.CommonFunctionHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：
 * @date ：
 *
 *
 * @version 1.0
 */
@RestController
@RequestMapping("/base/station/")
public class StationController {

    @Autowired
    StationService stationService;

    /**
   * D1-3查询岗位列表
   */
    @PostMapping("queryStationList")
    public OkrResult<QueryStationListRespDto> queryStationList(@RequestBody @Validated QueryStationListReqDto reqDTO){
    Page<?> page = CommonFunctionHelper.startPage(reqDTO.getPageNum(),reqDTO.getPageSize());

        QueryStationListRespDto retData = stationService.queryStationList(reqDTO);

        retData.setPageNum(page.getPageNum());
        retData.setPageSize(page.getPageSize());
        retData.setTotalNum(page.getTotal());
        return OkrResult.success(retData);
    
    }

    /**
   * D1-3查询编制去重岗位列表 （边界）
   */
    @PostMapping("queryNoRepStationList")
    public OkrResult<QueryNoRepStationListRespDto> queryNoRepStationList(@RequestBody @Validated QueryNoRepStationListReqDto reqDTO){
    Page<?> page = CommonFunctionHelper.startPage(reqDTO.getPageNum(),reqDTO.getPageSize());

        QueryNoRepStationListRespDto retData = stationService.queryNoRepStationList(reqDTO);

        retData.setPageNum(page.getPageNum());
        retData.setPageSize(page.getPageSize());
        retData.setTotalNum(page.getTotal());
        return OkrResult.success(retData);
    
    }

    /**
   * D1-3查询岗位列表(边界)
   */
    @PostMapping("queryStationListBorder")
    public OkrResult<QueryStationListBorderRespDto> queryStationListBorder(@RequestBody @Validated QueryStationListBorderReqDto reqDTO){
    Page<?> page = CommonFunctionHelper.startPage(reqDTO.getPageNum(),reqDTO.getPageSize());

        QueryStationListBorderRespDto retData = stationService.queryStationListBorder(reqDTO);

        retData.setPageNum(page.getPageNum());
        retData.setPageSize(page.getPageSize());
        retData.setTotalNum(page.getTotal());
        return OkrResult.success(retData);
    
    }

    /**
   * D1-3查询职位列表（边界）
   */
    @PostMapping("queryPostListBorder")
    public OkrResult<QueryPostListBorderRespDto> queryPostListBorder(@RequestBody @Validated QueryPostListBorderReqDto reqDTO){
    Page<?> page = CommonFunctionHelper.startPage(reqDTO.getPageNum(),reqDTO.getPageSize());

        QueryPostListBorderRespDto retData = stationService.queryPostListBorder(reqDTO);

        retData.setPageNum(page.getPageNum());
        retData.setPageSize(page.getPageSize());
        retData.setTotalNum(page.getTotal());
        return OkrResult.success(retData);
    
    }

    /**
   * D1-3存档岗位
   */
    @PostMapping("archiveStation")
    public OkrResult<ArchiveStationRespDto> archiveStation(@RequestBody @Validated ArchiveStationReqDto reqDTO){
    return OkrResult.success(stationService.archiveStation(reqDTO));
    }

    /**
   * D1-3修改岗位
   */
    @PostMapping("updateStation")
    public OkrResult<UpdateStationRespDto> updateStation(@RequestBody @Validated UpdateStationReqDto reqDTO){
    return OkrResult.success(stationService.updateStation(reqDTO));
    }

    /**
   * D1-3新增岗位
   */
    @PostMapping("addStation")
    public OkrResult<AddStationRespDto> addStation(@RequestBody @Validated AddStationReqDto reqDTO){
    return OkrResult.success(stationService.addStation(reqDTO));
    }

    /**
   * D1-3修改职位
   */
    @PostMapping("updatePost")
    public OkrResult<UpdatePostRespDto> updatePost(@RequestBody @Validated UpdatePostReqDto reqDTO){
    return OkrResult.success(stationService.updatePost(reqDTO));
    }

    /**
   * D1-3新增职位
   */
    @PostMapping("addPost")
    public OkrResult<AddPostRespDto> addPost(@RequestBody @Validated AddPostReqDto reqDTO){
    return OkrResult.success(stationService.addPost(reqDTO));
    }

    /**
   * D1-3查询职位列表
   */
    @PostMapping("queryPostList")
    public OkrResult<QueryPostListRespDto> queryPostList(@RequestBody @Validated QueryPostListReqDto reqDTO){
    Page<?> page = CommonFunctionHelper.startPage(reqDTO.getPageNum(),reqDTO.getPageSize());

        QueryPostListRespDto retData = stationService.queryPostList(reqDTO);

        retData.setPageNum(page.getPageNum());
        retData.setPageSize(page.getPageSize());
        retData.setTotalNum(page.getTotal());
        return OkrResult.success(retData);
    
    }

    /**
   * D1-3查询岗位详情
   */
    @PostMapping("queryStationDetail")
    public OkrResult<QueryStationDetailRespDto> queryStationDetail(@RequestBody @Validated QueryStationDetailReqDto reqDTO){
    return OkrResult.success(stationService.queryStationDetail(reqDTO));
    }
}
